Software Development
Nested Classes and Lambda Expressions
Classes in Java: Creating & Using Anonymous Classes
Classes in Java: Implementing Functional Interfaces Using Lambdas
Classes in Java: Working with Static Nested, Inner, & Local Classes

Classes in Java: Creating & Using Anonymous Classes

Course Number:
it_jpncledj_02_enus
Lesson Objectives

Classes in Java: Creating & Using Anonymous Classes

  • discover the key concepts covered in this course
  • define and use anonymous classes
  • recognize how anonymous instances are objects
  • illustrate the finer points of anonymous classes
  • implement the built-in interfaces, Comparator and Runnable, with anonymous classes
  • perform filter operations with local and anonymous classes
  • summarize the key concepts covered in this course

Overview/Description
Anonymous classes in Java allow you to define code that use-and-throw. These are classes where you define and instantiate a class simultaneously and which are anonymous, i.e., do not have a name. These are perfect in scenarios where you want a class that implements a certain interface but will not be reused beyond where it is defined and accessed. Through this course, learn to create and use anonymous classes, recognizing how they are nested, inner, and unnamed classes that either implement an interface or derive from a base class. As you advance, explore some common use cases for anonymous classes. When you're finished with this course, you'll be able to create and use anonymous classes in Java correctly, with the correct syntax, and for the proper use case.

Target

Prerequisites: none

Classes in Java: Implementing Functional Interfaces Using Lambdas

Course Number:
it_jpncledj_03_enus
Lesson Objectives

Classes in Java: Implementing Functional Interfaces Using Lambdas

  • discover the key concepts covered in this course
  • define and use lambda expressions
  • compare and contrast lambda statements and expressions
  • recall how lambdas can only implement functional interfaces
  • implement interfaces with generic types using lambdas
  • mark functional interfaces with @FunctionalInterface annotation
  • recall how functional interface instances are objects
  • create Predicate, Consumer, Function, and Supplier interfaces
  • invoke static and instance methods using method references
  • invoke instance methods with types and invoke constructors using method references
  • summarize the key concepts covered in this course

Overview/Description
Lambda expressions allow you to define classes that implement single-method interfaces in a very concise and compact manner. This makes code that uses lambda functions easier to read and understand and much more maintainable. Lambda expressions can be made even more compact and readable by the use of method references. In this course, you will learn to create and use lambda expressions to implement functional interfaces. You will see that lambda expressions are essentially blocks of code that accept input arguments, perform operations, and return values. Lambda expressions can be used in any place where we use anonymous classes or a named class that implements an interface with just a single abstract method. You will see that lambdas can only be used to implement functional interfaces i.e. interfaces that have exactly one abstract method. Such interfaces are usually annotated using the @FunctionalInterface annotation which allows the compiler to detect if the single abstract method contract has been violated for such interfaces. You will understand and implement the four types or categories of functional interfaces, the Predicate, Function, Consumer, and Supplier interfaces. Finally, you will round this course off by exploring and implement method references which are essentially even more compact representations of lambda expressions. When you are finished with this course you will have the skills and knowledge to construct lambda expressions in the right way and use Predicates, Functions, Suppliers, and Consumers to process and store your objects.

Target

Prerequisites: none

Classes in Java: Working with Static Nested, Inner, & Local Classes

Course Number:
it_jpncledj_01_enus
Lesson Objectives

Classes in Java: Working with Static Nested, Inner, & Local Classes

  • discover the key concepts covered in this course
  • illustrate how nested static classes work
  • instantiate and use static nested classes
  • illustrate various aspects of nested static classes
  • recognize the limitations of static nested classes
  • define and use inner classes
  • access variables from inner classes
  • use inner classes to create iterators for data structures
  • define and use local classes
  • access fields within local classes
  • work with access modifiers and scopes in local classes
  • define local classes in initialization blocks
  • summarize the key concepts covered in this course

Overview/Description
Static nested and inner classes in Java are used when classes have a logical relationship with or are intimately associated with the outer class within which they are defined. Local classes are classes defined within a scope and can only be accessed and used within that scope. They're the perfect tools to use when you want to limit the visibility of your classes. Through this course, learn to create and use static nested classes defined within an outer class. Explore how a closer relationship with an outer class can be expressed using inner classes and why access modifiers do not apply to local classes. And define and use local classes created with a code block. When you're finished with this course, you'll be able to pick the right kind of class for your use case and correctly implement nested classes, inner classes, and local classes.

Target

Prerequisites: none

Close Chat Live